﻿using Server.Business;
using Server.Database;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Server.TCP
{
    [CommandID(1)]
    public class ImportProdPackage : BusinessCommand
    {
        public override byte[] Excute(byte[] bytes)
        {
            try
            {
                ProdFactory factory = new ProdFactory();
                IList<ProdDB> list = factory.Create(bytes);

                ProdBusiness business = new ProdBusiness();
                foreach (ProdDB prodDB in list)
                {
                    business.AddProd(prodDB);
                }

                return new byte[] { 1 };
            }
            catch (Exception ex)
            {
                return new byte[] { 0 };
            }


            
        }
    }
}
